//
//  NSData+MAAdv.h
//  MateAdv
//
//  Created by 茶 on 2023/9/8.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSData (MAAdv)

#pragma mark --📺-- encode and decode (编码或者解码Option)
@property (nonatomic, readonly) NSString *utf8String;
@property (nonatomic, readonly) NSString *hexString;

- (id)jsonValue;

+ (NSData *)ma_dataWithHexString:(NSString *)hexStr;

#pragma mark --📺-- aes256 (AES-256 加密Option)

/**
 Returns an encrypted NSData using AES.
 
 @param key   A key length of 16, 24 or 32 (128, 192 or 256bits).
 
 @param iv    An initialization vector length of 16(128bits).
 Pass nil when you don't want to use iv.
 
 @return      An NSData encrypted, or nil if an error occurs.
 */
- (NSData *)stds_aes256EncryptWithKey:(NSData *)key iv:(NSData *)iv;

/**
 Returns an decrypted NSData using AES.
 
 @param key   A key length of 16, 24 or 32 (128, 192 or 256bits).
 
 @param iv    An initialization vector length of 16(128bits).
 Pass nil when you don't want to use iv.
 
 @return      An NSData decrypted, or nil if an error occurs.
 */
- (NSData *)stds_aes256DecryptWithkey:(NSData *)key iv:(NSData *)iv;

@end

NS_ASSUME_NONNULL_END
